import 'package:flutter/material.dart';
import 'package:flutter_eve_plugin/components/ye_xiu/archives/radar_chat.dart';
import 'package:flutter_eve_plugin/constants/font_family.dart';
import 'package:flutter_eve_plugin/model/ye_xiu/achieves/archieves_ability_entity.dart';
import 'package:flutter_eve_plugin/utils/image_util.dart';
import 'package:flutter_eve_plugin/utils/screen_util.dart';

class ArchivesPersonFooterWidget extends StatefulWidget {
  final ArchievesAbilityEntity data;
  ArchivesPersonFooterWidget({Key key, this.data}) : super(key: key);

  _ArchivesPersonFooterWidgetState createState() =>
      _ArchivesPersonFooterWidgetState();
}

class _ArchivesPersonFooterWidgetState
    extends State<ArchivesPersonFooterWidget> {

  @override
  Widget build(BuildContext context) {
    List<RadarViewModel> dataList =  [];
    if (widget.data?.data != null && widget.data.data.length > 0) {
      // List<ArchievesAbilityDataSkillpropertieslistSkillproperty> list = [];
      List<ArchievesAbilityData> aData = widget.data.data;
      if (aData != null && aData.length > 0) {
        List<ArchievesAbilityDataSkillpropertieslist> properList = aData[0].skillPropertiesList;
        if (properList.length > 0 ) {
          Map<String,ArchievesAbilityDataSkillpropertieslistSkillproperty> properMap = properList[0]?.skillProperties;
          properMap.forEach((String key, ArchievesAbilityDataSkillpropertieslistSkillproperty e) {
                        dataList.add(RadarViewModel(
                text: '${e.value}\n${e.name}(${e.level}级)', value: setRatio(e.percent.floorToDouble()), color: Colors.white));
          });
          print('RadarViewModel $dataList');
        }
      }
    } else {
      dataList =  [
        RadarViewModel(
            text: '0\n心态(1级)', value: setRatio(0), color: Colors.white),
        RadarViewModel(
            text: '0\n战术(1级)', value: setRatio(0), color: Colors.white),
        RadarViewModel(
            text: '0\n意识(1级)', value: setRatio(0), color: Colors.white),
        RadarViewModel(
            text: '0\n体魄(1级)', value: setRatio(0), color: Colors.white),
        RadarViewModel(
            text: '0\n手速(1级)', value: setRatio(0), color: Colors.white),
      ];
    }

    return Container(
      width: setRatio(360),
      height: setRatio(310),
      margin: EdgeInsets.only(left: setRatio(7.5), top: setRatio(8)),
      decoration: BoxDecoration(
          image: DecorationImage(
              image: AssetImage(imageUtilYeXiu(
                  'archives/icon_archivers_person_footer_bg@3x')))),
      child: Stack(
        overflow: Overflow.visible,
        children: <Widget>[
          Container(
            width: setRatio(95),
            height: setRatio(26),
            margin: EdgeInsets.only(left: setRatio(6), top: setRatio(13)),
            decoration: BoxDecoration(
                image: DecorationImage(
                    image: AssetImage(imageUtilYeXiu(
                        'archives/icon_archivers_left_title_bg1@3x')))),
            child: Container(
              padding: EdgeInsets.only(left: setRatio(15), top: setRatio(3)),
              child: Text(
                '能力分析',
                style: TextStyle(
                    shadows: [
                      BoxShadow(
                          color: Color(0x47000000),
                          offset: Offset(0, setRatio(2)),
                          blurRadius: setRatio(2))
                    ],
                    decoration: TextDecoration.none,
                    letterSpacing: 1,
                    color: Color(0xFFFFFFFF),
                    fontFamily: FontFamily.PMZD,
                    fontSize: setTextSp(15)),
              ),
            ),
          ),
          Positioned(
            left: setRatio(30),
            top: setRatio(25),
            child: Container(
              height: setRatio(300),
              width: setRatio(300),
              child: CustomPaint(
                painter: RadarView(
                    radius: setRatio(100),
                    dataList: dataList,
                    userColor: Color(0xcFFFDD80),
                    bgColor: Color(0x30FFFFFF)),
              ),
            ),
          )
        ],
      ),
    );
  }
}
